/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jigdo.data.template.section.DESCEntries;

import jigdo.data.template.section.*;
import java.io.*;
import java.lang.StringBuilder;

/**
 * The range of data 
 * @author John R Sohn
 */
public class DATARange {
    
    public int getLength()
    {
        return this.EndIndex-this.StartIndex+1;
    }
    
    public String toString()
    {
       StringBuilder builder = new StringBuilder();
       
       builder.append("Start Index:");
       builder.append(StartIndex);
       builder.append("\r\n");
       
       builder.append("End Index: ");
       builder.append(EndIndex);
       builder.append("\r\n");
       
       return builder.toString();
    }
    
    
    /**
     * The data section from which this range draws values; 
     */
    public TemplateDATASection Source;
    
    
    /**
     * Represents the starting position in the source at which data begins being retrieved.
     */
    public int StartIndex;
    
    /**
     * Represents the end position in the source.
     */
    public int EndIndex;
    
    
    public void WriteToStream(OutputStream out) throws IOException
    {
        out.write(Source.UncompressedData, StartIndex, EndIndex-StartIndex+1);
        out.flush();
    }
    
    
}
